<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use Intervention\Image\ImageManagerStatic as Image;
use App\Http\Requests;
use DB;

class DetailsController extends CommonController
{
    
    public function index()
    {   
    		$list = DB::table("type")->get();
   		foreach($list as $v){
	   	 	//获取path中的逗号
	        $m = substr_count($v->path,',');
	        //生成缩进
	        $v->name = str_repeat(" &nbsp; ",($m-1)*2)."|--".$v->name;
       }
       return view("admin.comtable.details",["list"=>$list]);
       
    }
    
   public function create()
   {
   	$list = DB::table("type")->get();
   		foreach($list as $v){
	   	 	//获取path中的逗号
	        $m = substr_count($v->path,',');
	        //生成缩进
	        $v->name = str_repeat(" &nbsp; ",($m-1)*2)."|--".$v->name;
       }
       return view("admin.comtable.details",["list"=>$list]);
   }

   public function story(Request $request)
   {
   		$data = ['name'=>$request->name,'details'=>$request->details];

   		$list = DB::table('details')->insert($data);	
   		var_dump($list);
   		die;	
   		return view("admin.comtable");


   }
}
